var arr = [1, 2, 1, 2, 3, 4, 2, 3, 4, 23, 5, 6]
// console.log(arr.indexOf(1))
// lastIndexOf 从后向前查找 返回对应的下标  找不到返回-1
// console.log(arr.lastIndexOf(0))
// console.log(arr.includes(2))
// function arrayIndexOf(arr, item, fromStart){
//     if (!arr || arr.constructor !== Array) throw new Error(arr + "not is Array");
//     fromStart = ~~ fromStart;
//     if(fromStart <0) fromStart = (fromStart + arr.length)<0?0 :fromStart + arr.length
//     for(var i = fromStart;i<arr.length;i++){
//         //遇到空白跳出
//         if(!(i in arr)) continue
//         if(arr[i]===item) return i
//     }
//     return -1
// }
// console.log(arrayIndexOf(arr,2))
// function arrIncludes(arr,item){
//     if (!arr || arr.constructor !== Array) throw new Error(arr + "not is Array");
//     for(var i = 0;i<arr.length;i++){
//         if(!(i in arr)) continue
//         if(arr[i]===item) return true
//     }
//     return true
    
// }
// console.log(arrIncludes(arr,1))
// function arrayLastIndexOf(arr, item, fromEnd) {
//     if (!arr || arr.constructor !== Array) throw new Error(arr + "not is Array");
//     if (fromEnd === undefined) fromEnd = arr.length - 1
//     fromEnd = ~~fromEnd
//     if (fromEnd < 0) fromEnd = (fromEnd + arr.length) < 0 ? 0 : fromEnd + arr.length
//     for (var i = fromEnd; i >= 0; i--) {
//         //遇到空白跳出
//         if (!(i in arr)) continue
//         if (arr[i] === item) return i
//     }
//     return -1
// }
// console.log(arrayLastIndexOf(arr, 6))